package com.wangjinhai.service;

import com.wangjinhai.mapper.UserMapper;
import com.wangjinhai.test.test1.User1Mapper;
import com.wangjinhai.test.test2.User2Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private User1Mapper user1Mapper;
    @Autowired
    private User2Mapper user2Mapper;
    public int add(){
        return userMapper.insert("张三",18);
    }

    public int add1(){
        return user1Mapper.insert("张三",18);
    }
    public int add2(){
        return user2Mapper.insert("张三",18);
    }

    @Transactional
    public int add12(){
        int a = user2Mapper.insert("张三", 18);
        int i=1/0;
        int b = user1Mapper.insert("张三",18);
        return a+b;
    }
}
